package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class InputStreamDemo1 {
    public static void main(String[] args) throws InterruptedException {
        //1.创建流对象  try-catch-resource
            //3.关闭流
        try(InputStream inputStream=new FileInputStream("c.txt")){
            //2.读写操作
            while(true){
                int read = inputStream.read();
                //如果流返回的是-1，说明数据已经读取完了
                if(read==-1) {
                    break;
                }
                System.out.printf("%c",read);
                Thread.sleep(200);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
